// 1. 引入 vue 的依赖
import Vue from 'vue'
// 2. 引入 路由
import VueRouter from 'vue-router'
// 3. 自定义的组件

// 4. 在Vue 中使用路由  Vue.prototype.$router = router
Vue.use(VueRouter)

// 5. 配置路由项
const routes = [
  // 默认
  {
    path: "/",
    redirect: "/login"
  },
  // 404
  {
    path: "*",
    name: 'home404',
    component: () => import('../components/404.vue')
  },
  // 登录
  {
    path: '/login',
    name: 'Login',
    component: () => import('../components/Login.vue')
  },
  // 首页
  {
    path: '/home',
    name: 'Home',
    component: () => import('../components/Home.vue'),
    // children: [{
    //   path: 'about',
    //   component: () => import('../components/About.vue')
    // },]
  },
  // 展示营销
  {
    path: '/showOff-item1',
    name: 'showOff-item1',
    component: () => import('../components/showOff-item1.vue')
  },
  {
    path: '/showOff-item2',
    name: 'showOff-item2',
    component: () => import('../components/showOff-item2.vue')
  },
  {
    path: '/showOff-item3',
    name: 'showOff-item3',
    component: () => import('../components/showOff-item3.vue')
  },
  {
    path: '/showOff-item4',
    name: 'showOff-item4',
    component: () => import('../components/showOff-item4.vue')
  },
  {
    path: '/showOff-item4-m1',
    name: 'showOff-item4-m1',
    component: () => import('../components/showOff-item4-m1.vue')
  },
  {
    path: '/showOff-item4-m2',
    name: 'showOff-item4-m2',
    component: () => import('../components/showOff-item4-m2.vue')
  },
  // 教务教学
  {
    path: '/education-item1',
    name: 'education-item1',
    component: () => import('../components/education-item1.vue')
  },
  {
    path: '/education-item1-m1',
    name: 'education-item1-m1',
    component: () => import('../components/education-item1-m1.vue')
  },
  {
    path: '/education-item1-m2',
    name: 'education-item1-m2',
    component: () => import('../components/education-item1-m2.vue')
  },
  // 财务中心
  {
    path: '/finance-item1',
    name: 'finance-item1',
    component: () => import('../components/finance-item1.vue')
  },
  {
    path: '/finance-item1-m1',
    name: 'finance-item1-m1',
    component: () => import('../components/finance-item1-m1.vue')
  },
  {
    path: '/finance-item2',
    name: 'finance-item2',
    component: () => import('../components/finance-item2.vue')
  },
  {
    path: '/finance-item2-m1',
    name: 'finance-item2-m1',
    component: () => import('../components/finance-item2-m1.vue')
  },
  {
    path: '/finance-item3',
    name: 'finance-item3',
    component: () => import('../components/finance-item3.vue')
  },
  {
    path: '/finance-item4',
    name: 'finance-item4',
    component: () => import('../components/finance-item4.vue')
  },
  {
    path: '/finance-item5',
    name: 'finance-item5',
    component: () => import('../components/finance-item5.vue')
  },
  {
    path: '/finance-item6',
    name: 'finance-item6',
    component: () => import('../components/finance-item6.vue')
  },
  // 统计
  {
    path: '/statistics-item1',
    name: 'statistics-item1',
    component: () => import('../components/statistics-item1.vue')
  },
  {
    path: '/statistics-item2',
    name: 'statistics-item2',
    component: () => import('../components/statistics-item2.vue')
  },
  // 系统
  {
    path: '/system-item1',
    name: 'system-item1',
    component: () => import('../components/system-item1.vue')
  },
  {
    path: '/system-item2',
    name: 'system-item2',
    component: () => import('../components/system-item2.vue')
  },
  {
    path: '/system-item3',
    name: 'system-item3',
    component: () => import('../components/system-item3.vue')
  },
  {
    path: '/system-item4/',
    name: 'system-item4',
    component: () => import('../components/system-item4.vue')
  },
]
// 6. 生成路由实例
const router = new VueRouter({
  // 路由模式
  // mode: "history",
  routes
})
// 捕捉重复 导航套同一 路径 出现 warning 异常
const originPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (path) {
  return originPush.call(this, path).catch(err => err)
}
// 7. 导出路由实例
export default router